package com.syf.config.exception;

import com.syf.config.result.ResultCodeEnum;

/**
 * 公共异常枚举
 */
public enum CommonExceptionEnum implements ResultCodeEnum {


    /**
     * 权限和数据问题
     */
    DB_RESOURCE_NULL(501,"数据库中没有该资源"),
    NO_PERMITION(401, "权限异常"),
    REQUEST_INVALIDATE(400,"请求数据格式不正确"),
    REQUEST_CRITERIA_NULL(400,"请求参数为空"),
    INVALID_KAPTCHA(405,"验证码不正确"),
    CANT_DELETE_ADMIN(400,"不能删除超级管理员"),
    CANT_FREEZE_ADMIN(400,"不能冻结超级管理员"),
    CANT_CHANGE_ADMIN(400,"不能修改超级管理员角色"),
    SIGN_FAIL(401,"验签失败"),
    SING_ERROR(400,"验签失败"),


    /**
     * 账户问题
     */
    USER_ALREADY_REG(417,"该用户已经注册"),
    USERPHONE_ALREADY_REG(417,"该手机号已经存在"),
    USER_NOT_EXISTED(417, "没有此用户"),
    USER_NOT_ROLE(417, "用户没有角色"),
    ACCOUNT_FREEZED(417, "账号被冻结"),
    OLD_PWD_NOT_RIGHT(417, "原密码不正确"),
    TWO_PWD_NOT_MATCH(417, "两次输入密码不一致"),
    USER_NOT_LOGIN(417, "用户未登录"),
    ROLE_NOT_EXISTED(417, "没有此角色"),

    /**
     * 错误的请求
     */
    MENU_PCODE_COINCIDENCE(417,"菜单编号和副编号不能一致"),
    BRIDGE_DATA_ERROR(500,"获取厂家接口数据失败"),
    MENU_NOT_EXISTED(417,"菜单不存在"),
    EXISTED_THE_MENU(417,"菜单编号重复，不能添加"),
    DICT_MUST_BE_NUMBER(417,"字典的值必须为数字"),
    REQUEST_NULL(400, "请求有错误"),
    SESSION_TIMEOUT(500, "会话超时"),
    SERVER_ERROR(500, "服务器异常");

    private int code;
    private String msg;

    CommonExceptionEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
